<?php

namespace Common\Model;

/**
 * Description of HotelRoomCheckCostModel
 * 
 * @author wenhui
 */
class HotelRoomCheckCostModel extends BaseModel {

    protected $trueTableName = 'tb_hotel_room_check_cost';

    /**
     * 添加客栈记一笔数据
     * @modify wenhui 2017-12-19
     * @param array $data 封装好的信息
     * @return boolean          执行结果
     */
    public function addAllInfo($data) {
        $result = $this->addAll($data);

        return $result;
    }

    /**
     * 获取记录by hotelroomcheck_id
     * @modify wenhui 2017-12-19
     * @param int $checkId 
     * @return array  $data 执行结果
     */
    public function getInfoByCheckId($checkId) {
        if (is_array($checkId)) {
            $checkId = implode(',', $checkId);
        }

        if (strpos($checkId, ',') !== false) {
            $options['hotelroomcheck_id'] = array('in', $checkId);
        } else {
            $options['hotelroomcheck_id'] = $checkId;
        }

        $options['isdelete'] = NOT_DELETE;

        $data = $this->where($options)->select();
        return $data;
    }

    /**
     * 修改数据
     * @modify wenhui 2017-12-19
     * @param inetegr $hotelId  客栈id
     * @param string $noteId 客栈项目id
     * @param integer $name 名称
     */
    public function saveInfo($hotelId, $noteId, $name) {
        $options = array(
            'hotelentity_id' => $hotelId,
            'id' => $noteId,
        );
        $data['name'] = $name;

        $result = $this->where($options)->save($data);
        return $result === false ? false : true;
    }

     /**
     * 删除数据
     * @modify wenhui 2017-12-19
     * @param inetegr $id
     */
    public function deleteInfo($checkId, $roomCostId = null) {
        if (!is_null($roomCostId)) {
            if (is_array($roomCostId)) {
                $roomCostId = implode(',', $roomCostId);
            }

            if (strpos($roomCostId, ',') !== false) {
                $options['hotelroomcost_id'] = array('in', $roomCostId);
            } else {
                $options['hotelroomcost_id'] = $roomCostId;
            }
        }

        if (is_array($checkId)) {
            $checkId = implode(',', $checkId);
        }

        if (strpos($checkId, ',') !== false) {
            $options['hotelroomcheck_id'] = array('in', $checkId);
        } else {
            $options['hotelroomcheck_id'] = $checkId;
        }

        $options['isdelete'] = NOT_DELETE;
        $data['isdelete'] = IS_DELETE;

        $result = $this->where($options)->save($data);
        return $result === false ? false : true;
    }
}
